import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.regex.Pattern;

/**
 * This class is a network factory.
 *
 * @author liat
 * Last updater: Oded
 * Date: 29.7.09 15:00
 */
public class BuildNet {

	
	// public final String BASE_DIR = "C:/Documents and Settings/workspace/FunctionalAnnot/Project1/src/";
	public BuildNet() {
		
	}


	

	/**
	 * Reads the network file and constructs a new network based on it.
	 * @param netFileName the given network file.
	 * @return a network.
	 */
	/*
	public Network generateNet(String netFileName) {
		Network net = new Network();
		String fullNetFileName = Consts.DATA_DIR + netFileName;
		BufferedReader netFile = null;
		String line;
		String prot1 = null,prot2 = null;
		double confidence = 0;
		String conf = null;
// 		String[] netData; // TEMP TODO consider removing.
		try {
			netFile = new BufferedReader(new FileReader(fullNetFileName));
		} catch (IOException ioe) {
			System.err.println("Can't open file "+netFileName+" for reading");
			System.exit(1);
		}
		try {
			while( ( (line = netFile.readLine()) != null )) {
				Scanner lineScan = new Scanner(line).useDelimiter(Pattern.compile("[ \t\n\f\r]"));
				if (lineScan.hasNext()) {
					prot1 = lineScan.next();
				}
				if (lineScan.hasNext()) {
					conf = lineScan.next();
				}
				if (lineScan.hasNext()) {
					prot2 = lineScan.next();
				}
				if ((prot1 != null) && (prot2 != null)) {
					conf = conf.substring(1,conf.length()-1); //Remove ( and ) from the confidence.
					//System.out.println(prot1+"\t"+prot2+"\t"+conf);
					confidence = Double.valueOf(conf); // Convert to double.
					
					// Add edge and possible nodes to the network.
					net.addNode(prot1);
					net.addNode(prot2);					
					net.setEdge(prot1, prot2, confidence);

					lineScan.close();
					prot1 = null;
					prot2 = null;
				}
			}
			netFile.close();
		} catch (IOException ieo) {
			System.err.println("having trouble reading file "+ netFile.toString());
			System.exit(1);
		}
		return net;
	}
	*/
	/**
	 * Creates new nodes and combines them with an edge to the network.
	 * @param prot1 the name of the first protein.
	 * @param prot2 the name of the second protein.
	 * @param conf the confidence as to the interaction between the proteins.
	 * @param net - Biological network.
	 *//*
	private void updateNetwork(String prot1, String prot2, double conf, Network net) {	
		net.setEdge(prot1, prot2, conf);
	}*/
}